<%@ page import="com.tlb.ejb.*,com.tlb.dto.*,com.tlb.web.*,java.util.*" %>
<% 
java.text.SimpleDateFormat toFormat = new java.text.SimpleDateFormat("MM/dd/yy hh:mm a");
String parDate = "";
    
Poster p = new AuthManager(request, response).hardAuthenticatePoster();




int x = 0;

if(request.getParameter("postId") == null || Integer.parseInt(request.getParameter("postId")) < 1) {
    System.out.println("Error in editStart:  bad postId: " + request.getParameter("postId"));
    request.getRequestDispatcher("/index.jsp").forward(request, response);
}
if(request.getParameter("threadId") == null || Integer.parseInt(request.getParameter("threadId")) < 1) {
    System.out.println("Error in editStart:  bad threadId: " + request.getParameter("threadId"));
    request.getRequestDispatcher("/index.jsp").forward(request, response);
}

try {
    if(request.getParameter("x") == null || request.getParameter("x").trim().equals(""))
        throw new Exception("Null x passed");
    x = Integer.parseInt(request.getParameter("x"));
    if(x < 1)
        throw new Exception("Invalid x passed: " + x);
} catch(Exception e) {    
        out.println("Edit Start Error (x): " + e.getMessage());
        out.flush();
        return;
}





ThreadDAO tdao = new ThreadDAO();
PostContent pc = (PostContent)(tdao.getPostById(Integer.parseInt(request.getParameter("postId"))));

try {
    parDate = toFormat.format(new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm").parse(pc.getPost().getPostDate().substring(0,16)));
} catch(Exception e) {    
    parDate = "Parse Error: " + e.getMessage();
}


%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>Big<%=Util.getUtil().getBoard(request)==Util.BCB?"College":"Law"%>Board.com</title>
	<link rel="stylesheet" type="text/css" href="ext/tlbStyle.css" />
        <link rel="shortcut icon" href="ext/c_sailboat.gif">
	<script type="text/javascript" src="ext/tlbMenu.js" />
	<script type="text/javascript">
		window.onload = initLeftMenu;
	</script>
        <script>
            function submitEdit(form) {
	    	document.getElementById('editBtn').disabled=true;
	    	form.submit();
	    }            
        </script>
</head>

<body >
<center>
<div id="mainContainer">
<table>

<tr>
<td valign="top">

	<div id="contentContainer" style="background-color:#FFFFFF">
		<h1>Edit Post</h1><br>

                    <div style="font-family:Times New Roman,MS Sans Serif;font-size:medium;px">
                    <b>Author:</b> <%= pc.getMoniker().getName() %> [<%= pc.getMoniker().getPostCount() %>] (<i><%= pc.getMoniker().getTagLine() %></i>)
                    <br>
                    <b>Originally Posted:</b> <%= parDate %>
                    <br><br>

<hr noshade size=1 width="100%">
                <br>
                
            <div id="editTemplate">
                    <form method=post action=editPost.jsp>
                    <input type=hidden name=editPostId id=editPostId value="<%= request.getParameter("postId") %>">
                    <input type=hidden name=threadId value="<%= request.getParameter("threadId") %>">
                    <input type=hidden name=x value="<%= x %>">
                    <table width=100% border=0>
                            <tr><td valign=top><b>Post: </b></td><td><textarea rows=10 cols=60 wrap=virtual name=content><%= pc.getContent() %></textarea></td></tr>
                            <tr><td>&nbsp;</td><td><input onclick="submitEdit(this.form)" type=button class=btn id="editBtn" value="Save Edit">&nbsp;<input type=button class=btn value="Cancel" onclick="javascript: document.location='viewThread.jsp?threadId=<%=request.getParameter("threadId")%>&x=<%=x%>'"></td></tr>
                    </table>
                    </form>
            </div>
               

	</div>
</td>
</tr>
</table>

</div>
</center>
<!-- Start of StatCounter Code -->
<script type="text/javascript">
var sc_project=2753481; 
var sc_invisible=0; 
var sc_partition=27; 
var sc_security="fadeb289"; 
</script>
<script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script><noscript><div class="statcounter"><a class="statcounter" href="http://www.statcounter.com/"><img class="statcounter" src="http://c28.statcounter.com/2753481/0/fadeb289/0/" alt="blog stats" /></a></div></noscript>
<!-- End of StatCounter Code -->

</body>
</html>